package com.miao.UserClass;


import com.miao.entity.Food;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.config.BeanPostProcessor;


/**
 * Description:  Bean的后置处理器 ---在Bean初始化的前后进行处理
 * Author: Miao@ShaoQing
 * Data: 16:29 2021/5/12
 */
public class MyBeanPostProcessor implements BeanPostProcessor {



    // 初始化方法调用之前进行调用！
    @Override
    public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException {
        if(bean instanceof Food){
            System.out.println("==》BeanPostProcessor接口:前置处理postProcessBeforeInitialization");
        }
        return bean;
    }


    // 初始化方法调用之后进行调用！
    @Override
    public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {
        if(bean instanceof Food){
            System.out.println("==》BeanPostProcessor接口:后置处理postProcessAfterInitialization");
        }
        return bean;
    }



}
